package com.lyl.utils;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SysInterceptor extends HandlerInterceptorAdapter {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object user = request.getSession().getAttribute(ResUtil.LOGINUSER);
        if (user == null) {// 没有登录  请先登录
            //1.重定向去 401  错误提示页面
            response.sendRedirect(request.getContextPath() + "/401.jsp");
            return false;// 返回不能往后面流程走了
        }


        return true;//放你走
    }
}
